package pers.xhh.shopapi.common;

/**
 * @description:
 * 统一结果返回类
 * @author: wei-xhh
 * @create: 2020-09-27
 */
public class Mi {

    private Object data;
    private MetaObj meta;

    public static Mi error(String msg, Integer status){
        Mi mi = new Mi();
        MetaObj metaObj = new MetaObj();
        metaObj.setMsg(msg);
        metaObj.setStatus(status);
        mi.setMeta(metaObj);
        mi.setData("");
        return mi;
    }

    public static Mi ok(String msg, Integer status, Object o){
        Mi mi = new Mi();
        MetaObj metaObj = new MetaObj();
        metaObj.setMsg(msg);
        metaObj.setStatus(status);
        mi.setMeta(metaObj);
        mi.setData(o);
        return mi;
    }

    static class MetaObj {
        private String msg;
        private Integer status;

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public Integer getStatus() {
            return status;
        }

        public void setStatus(Integer status) {
            this.status = status;
        }
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public MetaObj getMeta() {
        return meta;
    }

    public void setMeta(MetaObj meta) {
        this.meta = meta;
    }
}
